import request from '@/utils/request'
import { apiVersion } from '@/config'

// 全部列表
export function getAllExperiments(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/all`,
    method: 'get',
    data
  })
}
export function getExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment`,
    method: 'get',
    data
  })
}

/**
 * 获取非停止状态的列表
 * @param {} data 
 */
export function getExperimentMonitor(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/monitor`,
    method: 'get',
    data
  })
}
/**
 * 添加
 * @param {} data 
 */
export function addExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment`,
    method: 'post',
    data: data
  })
}
/**
 * 删除
 * @param {} data 
 */
export function delExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}`,
    method: 'delete',
    data
  })
}
/**
 * 启动
 * @param {} data 
 */
 export function startExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}/start`,
    method: 'put',
    data
  })
}
/**
 * 停止
 * @param {} data 
 */
 export function stopExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}/stop`,
    method: 'put',
    data
  })
}
/**
 * 更新
 * @param {} data 
 */
export function putExperiment(data) {
  return request({
    url: `/admin/${apiVersion}/experiment`,
    method: 'put',
    data: data
  })
}
/**
 * 取得详情
 * @param {*} data 
 */
export function getExperimentDetail(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}`,
    noLoadding: true,
    method: 'get',
  })
}
/**
 * 获取podname
 * @param {*} data 
 */
export function getexperimentPodName(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}/podName`,
    noLoadding: true,
    method: 'get',
  })
}
/**
 * 获取指标或图示数据详情
 * @param {*} data 
 */
export function metricData(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}/metric/data`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}
/**
 * 获取指标或图示名称
 * @param {*} data 
 */
export function metricKeys(data) {
  return request({
    url: `/admin/${apiVersion}/experiment/${data.id}/metric/keys`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}

/**
 * 获取ssh地址
 * @param {*} data 
 */
 export function getSsh(id) {
  return request({
    url: `/admin/${apiVersion}/experiment/${id}/ssh`,
    noLoadding: true,
    method: 'get',
  })
}


/**
 * 创建PVC
 * @param {} data
 */
export function createPvc(data) {
	return request({
		url: `/admin/${apiVersion}/experiment/${data.id}/createPvc`,
		method: "put",
		data: data,
	});
}

/**
 * 删除PVC
 * @param {} data
 */
export function deletePvc(data) {
	return request({
		url: `/admin/${apiVersion}/experiment/${data.id}/deletePvc`,
		method: "put",
		data: data,
	});
}

/**
 * 深度学习模型开发运行文件(航天智能院)
 * @param {*} command
 * @param {*} gameId
 */
export function notebookRunFile({ command:command, game_id:gameId }) {
	return request({
		url: `/admin/${apiVersion}/experiment/execCommand`,
		method: "post",
		data: { command:command, game_id:gameId },
	});
}